#include<iostream>
#include<cstdio>
using namespace std;
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	int ans=0;
	for(int i=l;i<=r;i++){
		int x=i%n;
		if(x==(n-1)){
			ans=x;
			break;
		}
		ans=max(ans,x);
	}
	cout<<ans;
	return 0;
}
